package com.ruoyi.lvlian.mapper;

import java.util.HashMap;
import java.util.List;

import com.ruoyi.lvlian.domain.*;
import com.ruoyi.lvlian.dto.*;
import com.ruoyi.lvlian.vo.DashboardVo;
import com.ruoyi.lvlian.vo.GetInvoiceDetailsVO;
import com.ruoyi.lvlian.vo.InvoiceVo;
import com.ruoyi.lvlian.vo.PaymentInfoVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

/**
 * 发票信息Mapper接口
 *
 * @author liyuxi
 * @date 2024-05-09
 */
@Repository
public interface InvoiceInfoMapper {
    /**
     * 查询发票信息
     *
     * @param id 发票信息主键
     * @return 发票信息
     */
    public InvoiceVo selectInvoiceInfoById(String id);


    /**
     * 根据税率获取发票信息列表 - 税率为 13 %
     * @param invoiceInfo
     * @return
     */
//    public List<InvoiceVo> selectInvoiceInfoList(InvoiceInfoDto invoiceInfo);


    /**
     * 根据税率获取发票信息列表 - 税率为 3 %
     *
     * @param invoiceInfo
     * @return 发票信息
     */
    public List<InvoiceVo> selectInvoiceInfoListByTaxRate(InvoiceInfoDto invoiceInfo);

    /**
     * 新增发票信息
     *
     * @param invoiceInfo 发票信息
     * @return 结果
     */
    public int insertInvoiceInfo(InvoiceInfo invoiceInfo);

    /**
     * 修改发票信息
     *
     * @param invoiceInfo 发票信息
     * @return 结果
     */
    public int updateInvoiceInfo(InvoiceInfo invoiceInfo);

    /**
     * 删除发票信息
     *
     * @param id 发票信息主键
     * @return 结果
     */
    public int deleteInvoiceInfoById(String id);

    /**
     * 批量删除发票信息
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteInvoiceInfoByIds(String[] ids);

//    List<String> selectRowIdByInvoiceRowId(String rowId);

    // 查询发票号码对应的Id
    String selectIdByInvoiceNum(String invoiceNum);



    List<PaymentInfoVo> queryInvoicePaymentInfoRefList(String invoiceId);

/*    List<RecyclingInInfoVo> queryInvoiceRecyclingRefList(String invoiceId);
    List<RenewableInInfoVo> queryInvoiceRenewableInInfoRefList(String invoiceId);
    List<RenewableInInfoVo> queryRenewableInInfoJoinContractList(RenewableInInfoDto renewableInInfoDto);*/
    void deleteInvoicePaymentUseAmountBatch(String[] ids);

    void deleteRefByInvoiceId(String invoiceId);

    void deleteInvoiceRenewableInInRefUseAmountBatch(String[] ids);


    void batchDeleteDetails( @Param("ids")  String[] ids );




    int deleteInvoicePaymentUseAmountList(@Param("invoiceId") String invoiceId, @Param("paymentId") String paymentId);

    public List<InvoiceVo>  selectInvoiceePaymentRefAndRecyclingRef(InvoiceInfoDto invoiceInfo);

    public List<InvoiceVo>  selectInvoicePaymentRefAndRenewableRef(InvoiceInfoDto invoiceInfo);

    List<InvoiceVo> queryInvoiceInfoList(InvoiceInfoDto invoiceInfo);

    List<HashMap<String, Object>> querySettlementAmountByInvoiceNum(String invoiceNum);

    List<HashMap<String, Object>> queryPaymentAmountByInvoiceNum(String invoiceNum);

    List<HashMap<String, Object>> queryContractInfoByInvoiceNum(String invoiceNum);

    List<InvoiceVo> queryInvoiceInfoListByInNum(InvoiceInfoDto invoiceInfo);

    List<InvoiceVo> queryInvoiceInfoListByPaymentNum(InvoiceInfoDto invoiceInfo);

    int batchSave(@Param("dtoList")  List<InvoiceInfo> dtoList);

    int bachSaveDetails(@Param("dtoList")  List<InvoiceDetails> dtoList);

    int bachSavePaymentRef(@Param("dtoList")  List<InvoiceInfoPaymentRef> dtoList);
    int bachSaveInWarehouse(@Param("dtoList")   List<InvoiceWarehouseRef> dtoList);

    int bachSaveContractRef(@Param("dtoList") List<InvoiceContractRef> dtoList);


    public int updateLogisticsStatusByInvoiceNum(@Param("logisticsStatus") String logisticsStatus, @Param("invoiceNum") String invoiceNum);

    int flushInvoiceImg();

    void batchDelete( @Param("ids")  String[] ids );

    void batchDeleteWarehouse(@Param("invoiceNumArr") String[] invoiceNumArr,@Param("warehouseNumArr")  String[] warehouseNumArr);

    DashboardVo queryInvoiceInfoAgg(@Param("category") String category,@Param("warehouseNum")  String warehouseNum, @Param("settlementAmount") String settlementAmount,
                                    @Param("buyerName") String buyerName,@Param("sellerName")  String sellerName);


    int updateImg(@Param("invoiceNum")String invoiceNum,  @Param("colName") String colName);
}
